function loginname(){
	var name=document.getElementById('name').value;
	if(!name){
		if(!document.getElementById('note')){
		 	$(".name").append("<p id='note'>*请输入账号</p>")
		 	$(".name p").addClass("append");
		 	$(".name p").addClass("addmargin");
			$("#name").addClass("red")     
		}
	}
	else{
		 if(document.getElementById('note'))
		 {
		 	$(".name p").remove();
		 	$("#name").removeClass("red");
		 }
	}
}
function loginpassword(){
	var passname=document.getElementById('password').value;
	if(!passname){
		if(!document.getElementById('ps')){
		 	$(".password").append("<p id='ps'>*请输入密码</p>")
		 	$(".password p").addClass("append");
		 	$(".password p").addClass("addmargin");
			$("#password").addClass("red");
			$(".forget").addClass("forgetmargin");
		}
	}
	else{
		if(document.getElementById('ps'))
		 {
		 	$(".password p").remove();
		 	$("#password").removeClass("red");
		 	$(".forget").removeClass("forgetmargin");
		 }
	}
}
function login(){
	/*var thisURL = decodeURI(document.URL);   // 获取当前页面的 url, 用decodeURI() 解码
    var getVal = thisURL.split('?')[1];
    var showVal= getVal.split("=")[1]; */
	var name=$("#name").val();
	var passname=$("#password").val();
	if(name&&passname)
	{
		$.ajax({
    	type: "post",
   		url: ip+"/login",
  		data: JSON.stringify({
  			username:name,
  			password:passname}),
    	async: true,
    	dataType: "json",
    	contentType: "application/json",
     	xhrFields: {withCredentials: true},
    	crossDomain:true,
    	success: function(res) {
    		console.log(res)
     		if(res.code==0)
     		{
     			$.ajax({
     				type: "get",
   					url: ip+"/user/type",
  					data:{
  						
  					},
    				async: true,
    				dataType: "json",
     				xhrFields: {withCredentials: true},
    				crossDomain:true,
    				success: function(res) {
    					console.log("sssss")
    					console.log(res)
						if(res.code==0)
						{
						}  
    				}
     			});
     			window.location.href="list.html";
     		}
     		else{
				jqalert({
   					title: '提示',
   					content: res.msg
  				})
			}
  		},
    	Error: function() {
      		alert("服务器出错");
    	}
    });
  }
	else{
		loginname();
		loginpassword();
	}
}
